<div id="header">
	<div id="logo">
		<div id="logo-left"></div>
		<div id="logo-right">Xin chào, <span class="black"><?php echo $_SESSION['username']." ";?></span> 
			<a href="#" class="img-admin">&nbsp;</a>
			<ul>
				<li><a href="<?php echo base_url()?>back_end/admin_ahashop/infomation">- Information</a></li>
				<li><a href="<?php echo base_url()?>" target="_blank">- Homepage</a></li>
				<li><a href="<?php echo base_url()?>back_end/admin/logout">- Logout</a></li>                      
			</ul>
		</div>
		<div class="clear"></div>
	</div>
	<div id="menu-top">
	<?php
		if($_SESSION['admin_id'] == 1){
			$menu_1		   = $this->db->get_where('admin_menu_1', array('status'=>1))->result_array();
			$menu_2		   = $this->db->get_where('admin_menu_2', array('status'=>1))->result_array();
			$url_segment = $this->uri->segment(2);
			switch ($url_segment)
			{
				case "admin_admin":
					$active = 0;
					break;
				case "admin_menu":
					$active = 1;
					break;
				case "admin_category":
					$active = 2;
					break;
				case "admin_news":
					$active = 3;
					break;
				default:
					$active = 0;
					break;	
			}
	?>
	
	<ul id="jsddm" class="left">
		<?php 
			$i = 0;
			foreach ($menu_1 as $menu1){
		?> 	
			<li><a href="<?php echo base_url().'back_end/'.$menu1['link']?>" class="white"><?php echo $menu1['name']?></a> 
				<ul <?php if ($active == $i){ echo 'style="display: block;"';}?>>
					<?php foreach ( $menu_2 as $m2 ) 
					{
						if ($menu1 ['id'] == $m2 ['admin_menu_1']) 
						{
					?>
							<li><a class="white" href="<?php echo base_url ().'back_end/'.$m2 ['link']?>"><?php echo $m2 ['name'];?></a></li>
					<?php 
						} 
					}?>
				</ul>
			</li>
			<li>|</li>
		<?php 
			$i++;}			
		?>
	</ul>							
	<?php }else{
			$admin_id      = $_SESSION['admin_id'];
			$table_admin   = $this->db->get_where('admins', array('id' => $admin_id));
			$admin         = $table_admin->row_array();
			$admin_permiss = $this->db->get_where('admin_permiss', array('group_admin_id' => $admin['admin_group_id'], 'access' => '1'));
				?>	
		<ul id="jsddm" class="left">
				<?php 
			if($admin_permiss->num_rows() >0){
				foreach($admin_permiss->result_array() as $permiss){
					$menu_1		 = $this->db->get_where('admin_menu_1', array('id' => $permiss['menu_admin_id']))->result_array();
					$menu_2		 = $this->db->get_where('admin_menu_2', array())->result_array();
					$i	= 0;		
					
				?> 	
					<?php
						foreach ($menu_1 as $menu1){ 
					?>					
						<li><a href="<?php echo base_url().'back_end/'.$menu1['link']?>" class="white"><?php echo $menu1['name']?></a>
							<ul>
								<?php foreach ( $menu_2 as $m2 ) 
								{

									if ($menu1 ['id'] == $m2 ['admin_menu_1']) 
									{
								?>
										<li><a class="white" href="<?php echo base_url ().'back_end/'.$m2 ['link']?>"><?php echo $m2 ['name'];?></a></li>
								<?php 
									} 
								}?>
							</ul>
						</li>
						<li>|</li>
		<?php
						$i++;}
					}  
				}							
			}		
		?>
		</ul>
				
		<div class="float-right-menu">
			<a href="#">Hỗ trợ</a>
		</div>

	</div>        
</div><!-- end header -->